package com.ydlclass;

import com.ydlclass.ChannelHandler.ConsumerChannelInitializer;
import io.netty.bootstrap.Bootstrap;
import io.netty.channel.*;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioSocketChannel;
import lombok.extern.slf4j.Slf4j;

/**
 * 来实现Bootstrap的初始化，单例
 * todo: 这里会有是呢嘛问题
 * @Author duWenJian
 * @Date 2024/2/18 15:34
 * @Version 1.0
 */
@Slf4j
public class NettyBootstrapInitializer {

    public static final Bootstrap bootstrap = new Bootstrap();

    static {
            EventLoopGroup group = new NioEventLoopGroup();
            bootstrap.group(group)
                    .channel(NioSocketChannel.class)
                    .handler(new ConsumerChannelInitializer());
    }

    private NettyBootstrapInitializer() {
    }

    public static Bootstrap getBootstrap() {
        return bootstrap;
    }
}
